From ede2583fa1a28a969c5609b86aa82a7ba9f19a26 Mon Sep 17 00:00:00 2001 From: Roman Skakun Date: Wed, 6 Jan 2021 13:26:57 +0200 Subject: [PATCH] xen/arm: optee: The function identifier is always 32-bit Per the SMCCC specification (see section 3.1 in ARM DEN 0028D), the function identifier is only stored in the least significant 32-bits. The most significant 32-bits should be ignored. Signed-off-by: Roman Skakun Acked-by: Volodymyr Babchyk [jgrall: Reword the commit message and comment] Acked-by: Julien Grall --- xen/arch/arm/tee/optee.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c index ee85359742..9570dc6771 100644 --- a/xen/arch/arm/tee/optee.c +++ b/xen/arch/arm/tee/optee.c @@ -1643,7 +1643,11 @@ static bool optee_handle_call(struct cpu_user_regs *regs) if ( !ctx ) return false; - switch ( get_user_reg(regs, 0) ) + /* + * The function identifier is always stored in the least significant + * 32-bit (see section ARM DEN 0028D). + */ + switch ( (uint32_t)get_user_reg(regs, 0) ) { case OPTEE_SMC_CALLS_COUNT: set_user_reg(regs, 0, OPTEE_MEDIATOR_SMC_COUNT); -- 2.30.2